<?php
/*
    Copyright (C) 2008 - 2009 Inanta Martsanto
    
    This file is part of Koma.

    Koma is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Koma is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Koma.  If not, see <http://www.gnu.org/licenses/>.
    
    Inanta Martsanto (inanta@inationsoft.co.cc)
*/

function shutdown()
{
    $is_error = false;

    if ($error = error_get_last())
    {
	switch($error['type'])
	{
		case E_ERROR:
		case E_CORE_ERROR:
		case E_COMPILE_ERROR:
		case E_USER_ERROR:
			$is_error = true;
			break;
	}
    }

    if ($is_error)
    {    
	show_message(T_('PHP Fatal Error'),
		     sprintf(T_('KOMA Error Message: %s<br/>File: %s line %s'), $error['message'], str_replace(KOMA_ROOT_PATH.'/', "", $error['file']), $error['line']));
    }
    else
    {
	if(ob_get_contents())
	{
	    ob_end_flush();
	}
    }
}
?>